home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* FILE: recvmdm7.c (MODEM7 file name receiver) */
- /* */
- /* */
- /* The Opus Computer-Based Conversation System */
- /* (c) Copyright 1986, Wynn Wagner III, All Rights Reserved */
- /* */
- /* */
- /* (MSC/4 with /Zp /Ox) */
- /* */
- /* */
- /* */
- /* */
- /* This module is similar to a routine used by Opus-Cbcs (1.00). It is */
- /* provided for your information only. You will find routines that need */
- /* to be coded and identifiers to be resolved. */
- /* */
- /* There is absolutely no guarantee that anything here will work. If you */
- /* break this routine, you own both pieces. */
- /* */
- /* USAGE: You may use this material in any program with no obligation */
- /* as long as there is no charge for your program. For more */
- /* information about commercial use, contact the "OPUSinfo HERE" */
- /* BBS (124/111). */
- /* */
- /* */
- /*--------------------------------------------------------------------------*/
-
- #include "xfer.h"
- #include "com.h"
- #include <stdio.h>
-
- /*--------------------------------------------------------------------------*/
- /* From RECVMDM7.C */
- /*--------------------------------------------------------------------------*/
- extern char *_s_mdm7fname;
- extern char *_s_mdm7giveup;
- extern char *_s_mdm7idunno;
- extern char *_s_mdm7chksum;
- extern char *_s_mdm7nak;
- extern char *_s_mdm7toolong;
-
-
-
- /* ------------------------------------------------------------------------ */
- /* TeLink batch mode file name mini-header */
- /* ------------------------------------------------------------------------ */
- int recvmdm7( fname )
- char *fname;
- begin
- register int i,j;
- int got_dot;
- int retbyte;
- int tries;
- int xchksum;
- int got_eot;
- char *stat = NOTHING_msg;
- char tempname[30];
-
- clearbrk(); /* ww */
- brk_disable(); /* ww */
- XON_DISABLE(); /* ww */
-
- set_xy("");
-
- tries = got_eot = 0;
-
- if (PEEKBYTE()==0xffff) SENDBYTE(NAK);
-
-
- top:
-
- message(NULL);
-
- i = got_dot = 0;
- tries++;
-
- setmem( tempname, 30, '\0' );
- setmem( fname, 30, '\0' );
-
- while( (CARRIER) and (tries<8) )
- begin
- switch ( retbyte = TIMED_READ(3) )
- begin
- case SUB :
- /*--------------------------------------------*/
- /* SUB */
- /*--------------------------------------------*/
- if (!i)
- begin
- if (tries<4) goto top;
- else
- begin
- return(0);
- end
- end
-
- for(xchksum=SUB,i=0; tempname[i]; i++)
- xchksum += tempname[i];
- CLEAR_INBOUND();
- SENDBYTE( xchksum );
- retbyte = TIMED_READ(5);
- if (retbyte==ACK)
- begin
- /*---- Gussy up the name ---------------*/
- setmem(fname,30,'\0');
- for(
- i=j=got_dot=0;
- ( (tempname[i]) and (i<30) );
- i++
- )
- begin
- if (tempname[i]=='.') got_dot=1;
- else if ((i==8)&&(!got_dot))
- fname[j++] = '.';
- fname[j++] = tempname[i];
- end
-
- /* force BBS_STATUS to overwrite line */
- message(NULL);
- return 1;
-
- end
-
- got_eot = 0;
- SENDBYTE(NAK);
- goto top;
-
- case 'u' : /* Another error condition */
- case ACK :
- /*--------------------------------------------*/
- /* ACK */
- /*--------------------------------------------*/
- goto top;
-
- case EOT : /*--------------------------------------------*/
- /* EOT */
- /*--------------------------------------------*/
- stat = EOT_msg;
- SENDBYTE( ACK );
- if (got_eot>2) return 0;
-
- got_eot++;
- goto top;
-
- case CAN : /*--------------------------------------------*/
- /* CAN */
- /*--------------------------------------------*/
- stat = CAN_msg;
- goto fubar;
-
- default : /*--------------------------------------------*/
- /* Default */
- /*--------------------------------------------*/
- if (retbyte<' ')
- begin
-
- if (got_eot>2) return 0;
- else got_eot++;
-
- CLEAR_INBOUND();
-
- SENDBYTE( NAK );
- goto top;
- end
- if (i >= 30)
- begin
- stat = _s_mdm7toolong;
- goto fubar;
- end
- if ((retbyte>=' ') and (retbyte<='~'))
- begin
- tempname[i++]= (char )retbyte;
- putch( retbyte );
- end
- SENDBYTE( ACK );
- end /* switch */
- end /* while */
-
- fubar:
-
- if (tries>=16) stat = FUBAR_msg;
- cputs(stat);
-
- return 0;
-
- end /* get batchname */
-
- /* END OF FILE: recvmdm7.c */
-
-
-